package collection;

import java.util.Deque;
import java.util.LinkedList;

/**
 * 双端队列
 * Deque接口继承自Queue
 * 双端队列的特点是 队列两端 都可以进行出入队操作
 * 常用实现类：java.util.LinkedList
 */
public class DequeDemo {
    public static void main(String[] args) {
        Deque<String>deque = new LinkedList<>();
        deque.add("one");
        deque.add("two");
        deque.add("three");
        deque.add("four");
        System.out.println(deque);
        deque.offerFirst("five");
        System.out.println(deque);
        deque.offerLast("six");
        System.out.println(deque);

        String e = deque.poll();
        System.out.println(e);
        System.out.println(deque);

        e = deque.pollFirst();
        System.out.println(e);
        System.out.println(deque);

        e = deque.pollLast();
        System.out.println(e);
        System.out.println(deque);
    }
}
